<template>
  <div v-loading="qLoading" style="line-height:1.8" class="paperDetail_ori">
    <div v-if="qType==1||qType==2||qType==3||qType==4||qType==5">
      <div v-if="qType==1" >
        <div class="q-title" v-html="question.title"/>
        <div class="q-content">
          <el-radio-group v-model="question.correct">
            <el-radio  v-for="item in question.items"  :key="item.prefix"  :label="item.prefix" disabled>
              <span class="question-prefix">{{item.prefix}}.</span>
              <span v-html="item.content" class="q-item-span-content"></span>
            </el-radio>
          </el-radio-group>
        </div>
      </div>
      <div v-else-if="qType==2" >
        <div class="q-title" v-html="question.title"/>
        <div class="q-content">
          <el-checkbox-group v-if="question.items.length > 0" v-model="question.correctArray">
            <el-checkbox v-for="item2 in question.items" :key="item2.prefix" :label="item2.prefix" :value="item2.prefix" disabled>
              <span class="question-prefix">{{item2.prefix}}.</span>
              <span v-html="item2.content" class="q-item-span-content" />
            </el-checkbox>
          </el-checkbox-group>
        </div>
      </div>
      <div v-else-if="qType==3" >
        <div class="q-title" v-html="question.title" style="display: inline;margin-right: 10px"/>
        <span style="padding-right: 10px;">(</span>
        <el-radio-group v-model="question.correct">
          <el-radio  v-for="item in question.items"  :key="item.prefix"  :label="item.prefix" disabled>
            <span v-html="item.content" class="q-item-span-content"></span>
          </el-radio>
        </el-radio-group>
        <span style="padding-left: 10px;">)</span>
      </div>
      <div v-else-if="qType==4" >
        <div class="q-title" v-html="question.title"/>
        <!-- <div v-if="answer.contentArray!==null">
          <el-form-item :label="item.prefix" :key="item.prefix"  v-for="item in question.items"  label-width="50px" style="margin-top: 10px;margin-bottom: 10px;">
            <span v-html="item.content"  class="q-item-span-content"></span>
          </el-form-item>
        </div> -->
      </div>
      <div v-else-if="qType==5">
        <div class="q-title" v-html="question.title"/>
        <div>
          <el-input  v-model="answer.content" type="textarea" rows="5" disabled></el-input>
        </div>
      </div>
      <!-- <div class="question-answer-show-item" style="margin-top: 15px">
        <span class="question-show-item">结果：</span>
        <el-tag :type="doRightTagFormatter(answer.doRight)">
          {{ doRightTextFormatter(answer.doRight) }}
        </el-tag>
      </div> -->
      <div class="question-answer-show-item" style="margin-top: 20px">
        <span class="question-show-item2">分数：</span>
        <span style="color: red">{{question.score}}  分</span>
      </div>
      <div class="question-answer-show-item">
        <span class="question-show-item2">难度：</span>
        <el-rate disabled v-model="question.difficult" class="question-show-item"></el-rate>
      </div>
      <br/>
      <div class="question-answer-show-item" style="line-height: 1.8; display: block" >
        <span class="question-show-item2">解析：</span>
        <span v-if="question.analyze === ''" class="q-item-span-content" style="color: rgb(188, 188, 188)">暂无</span>
        <span v-else v-html="question.analyze" class="q-item-span-content"  style="color: #0ddcde; font-size: 1rem; letter-spacing: 0.9px;" />
      </div>
      <div class="question-answer-show-item">
        <span class="question-show-item2" style="color: #008eff">正确答案：</span>
        <span v-if="qType==1||qType==2 ||qType==5" v-html="question.correct" class="q-item-span-content"/>
        <span v-if="qType==3" v-html="trueFalseFormatter(question)" class="q-item-span-content"/>
        <!-- <span v-if="qType==4" v-html="question.correctArray" /> -->
        <el-row v-if="qType==4">
          <el-form-item :key="item"  v-for="(item,index) in question.correctArray" class="stuAns"  label-width="50px" style="margin-top: 10px;margin-bottom: 10px;">
            <el-input :value="index +'.   ' + item" :title="item" disabled></el-input>
            <br/>
          </el-form-item>
        </el-row>
      </div>
    </div>
    <div v-else>
    </div>
  </div>

</template>

<script>
import { mapState, mapGetters } from 'vuex'
export default {
  name: 'QuestionShow2',
  props: {
    question: {
      type: Object,
      default: function () {
        return {}
      }
    },
    answer: {
      type: Object,
      default: function () {
        return { id: null, content: '', contentArray: [], doRight: false }
      }
    },
    qType: {
      type: Number,
      default: 0
    },
    qLoading: {
      type: Boolean,
      default: false
    },
  },
  created () {
  },
  methods: {
    trueFalseFormatter (question) {
      return question.items.filter(d => d.prefix === question.correct)[0].content
    },
    doRightTagFormatter (status) {
      return this.enumFormat(this.doRightTag, status)
    },
    doRightTextFormatter (status) {
      return this.enumFormat(this.doRightEnum, status)
    }
  },
  computed: {
    ...mapGetters('enumItem', ['enumFormat']),
    ...mapState('enumItem', {
      doRightEnum: state => state.exam.question.answer.doRightEnum,
      doRightTag: state => state.exam.question.answer.doRightTag
    })
  }
}
</script>

<style rel="stylesheet/scss"  lang='scss'>
.paperDetail_ori .question-answer-show-item {
  margin-top: 12px !important;
  font-size: 1rem;
  .question-show-item {
    float: left;
  }
  .question-show-item2 {
    float: left;
    /*color: #008eff;*/
    color: #000000;
  }

  .el-rate {
    line-height: 1.5;
  }
}

.paperDetail_ori .question-answer-show-item::first-child {
  margin-top: 30px !important;
}

.paperDetail_ori .el-checkbox__input.is-checked + .el-checkbox__label {
  color: #40c600;
}

.paperDetail_ori .el-checkbox__input.is-checked .el-checkbox__inner {
  background-color: #40c600;
  border-color: #40c600;
}

.paperDetail_ori .el-radio__input.is-checked + .el-radio__label {
  color: #40c600;
}

.paperDetail_ori .el-radio__input.is-checked .el-radio__inner {
  border-color: #40c600;
  background: #40c600;
}

.paperDetail_ori .stuAns .el-form-item__content {
  margin-left: 0px !important;
}

.paperDetail_ori .empty .el-input__inner {
  background-color: #F5F7FA;
  border-color: #dfe4ed;
  color: rgb(188, 188, 188) !important;
  cursor: not-allowed;
}

.paperDetail_ori .el-input.is-disabled .el-input__inner {
  background-color: #F5F7FA;
  border-color: #dfe4ed;
  color: #33363a;
  cursor: not-allowed;
}

</style>